<?php
require_once('../Entities/TestDetail.php');

class TestDetailDAO 
{
	function CreateTestDetail($item)
	{
		$sql = "insert into TestDetails(QuestionId ,TestId, Marks) values ('" . 
			$item->QuestionId . "','" . $item->TestId . "','" . $item->Marks . "');";
		mysql_query($sql);
	}
	
	function GetTestDetailByTestId($id)
	{
		$sql = "select * from TestDetails where TestId='" . $id . "';";
		$list = array();
		$result = mysql_query($sql);
		while($row = mysql_fetch_assoc($result))
		{
			$item = new TestDetail();
			$item->TestId = $row["TestId"];
			$item->QuestionId = $row["QuestionId"];
			$item->Marks = $row["Marks"];
			$list[] = $item;
		}
		return $list;
	}
	
	function DeleteTestDetailByTestId($testId)
	{
		$sql = "delete from TestDetails where TestId='" . $testId . "';";
		mysql_query($sql);
	}
}

?>